package controller

import (
	"github.com/gin-gonic/gin"
	"lab.com/biz"
	"lab.com/request"
)

type cForum struct {
	APIBase
}

// Forum .
var Forum = cForum{}

// PostAdd return post add
func (forum *cForum) PostAdd(c *gin.Context) {
	inputParams := request.PostAddReq{}
	if err := inputParams.CheckInputParams(c); err != nil {
		forum.Resp(c, nil, err)
		return
	}

	err := biz.Forum.PostAdd(c, inputParams)
	forum.Resp(c, nil, err)
}

// PostEdit return post edit
func (forum *cForum) PostEdit(c *gin.Context) {
	inputParams := request.PostEditReq{}
	if err := inputParams.CheckInputParams(c); err != nil {
		forum.Resp(c, nil, err)
		return
	}

	err := biz.Forum.PostEdit(c, inputParams)
	forum.Resp(c, nil, err)
}

// PostList return post list
func (forum *cForum) PostList(c *gin.Context) {
	inputParams := request.PostListReq{}
	if err := inputParams.CheckInputParams(c); err != nil {
		forum.Resp(c, nil, err)
		return
	}

	res,err := biz.Forum.PostList(c, inputParams)
	if err != nil{
		forum.Resp(c, nil, err)
		return 
	}
	forum.Resp(c, res, err)
}

// PostDetail return post detail
func (forum *cForum) PostDetail(c *gin.Context) {
	inputParams := request.PostDetailReq{}
	if err := inputParams.CheckInputParams(c); err != nil {
		forum.Resp(c, nil, err)
		return
	}

	res,err := biz.Forum.PostDetail(c, inputParams)
	if err != nil{
		forum.Resp(c, nil, err)
		return 
	}
	forum.Resp(c, res, err)
}
// CommentAdd return comment add
func (forum *cForum) CommentAdd(c *gin.Context) {
	inputParams := request.CommentAddReq{}
	if err := inputParams.CheckInputParams(c); err != nil {
		forum.Resp(c, nil, err)
		return
	}

	err := biz.Forum.CommentAdd(c, inputParams)
	forum.Resp(c, nil, err)
}

// CommentList return comment list
func (forum *cForum) CommentList(c *gin.Context) {
	inputParams := request.CommentListReq{}
	if err := inputParams.CheckInputParams(c); err != nil {
		forum.Resp(c, nil, err)
		return
	}

	res,err := biz.Forum.CommentList(c, inputParams)
	if err != nil{
		forum.Resp(c, nil, err)
		return 
	}
	forum.Resp(c, res, err)
}

// CommentUnfoldedList return comment list
func (forum *cForum) CommentUnfoldedList(c *gin.Context) {
	inputParams := request.CommentUnfoldedListReq{}
	if err := inputParams.CheckInputParams(c); err != nil {
		forum.Resp(c, nil, err)
		return
	}

	res,err := biz.Forum.CommentUnfoldedList(c, inputParams)
	if err != nil{
		forum.Resp(c, nil, err)
		return 
	}
	forum.Resp(c, res, err)
}

// CommentInnerList return comment list
func (forum *cForum) CommentInnerList(c *gin.Context) {
	inputParams := request.CommentInnerListReq{}
	if err := inputParams.CheckInputParams(c); err != nil {
		forum.Resp(c, nil, err)
		return
	}

	res,err := biz.Forum.CommentInnerList(c, inputParams)
	if err != nil{
		forum.Resp(c, nil, err)
		return 
	}
	forum.Resp(c, res, err)
}